<template>
	<view class="find">
		<scroll-view class="flex_l" scroll-y="true">
			<view class="flex_l_item" v-for="(item,index) in typeList" :key="index" @click="cietype(item,index)">
				<view :class="active == index?'textactive' : 'text'">
					{{item.name}}
				</view>
			</view>
		</scroll-view>
		<scroll-view class="flex_r" scroll-y="true" @scrolltolower='Bottoms'>
			<view class="flex_r_item" v-for="(item,index) in dataList" :key="index" @click="toDetail(item)">
				<view class="flex_item">
					<image :lazy-load='true' class="imgs" :src="httpimg+item.image" mode=""></image>
					<view class="ads">
						<view class="ads_l">
							<view class="tit">{{item.title}}</view>
							<view class="label_flex">
								<view v-for="(i,inde) in item.labelList" :key="inde">
									<view v-if="inde<2" :class="item.labelList.length>1?'labelts':'label' " >
										{{i.name}}
									</view>
								</view>
							</view>
						</view>
						<view class="btn">
							￥{{item.price}}
						</view>
					</view>
				</view>
			</view>
			<uni-load-more v-if="!dataList.length <= 0" :status="statusshow"></uni-load-more>
			<kong v-if="dataList.length <= 0"></kong>
		</scroll-view>
		<uv-tabbar :value="1" class="tab"></uv-tabbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				httpimg: this.$httpimg,
				active: 0,
				dataList: [],
				typeList: [],
				params: {
					sign: '111',
					page: 1,
					limit: 10,
					cate_id: 0,
					is_hot: 1
				},
				statusshow: 'loading'
			}
		},
		onShareAppMessage(res) {
			return {
				title: '陶溪川欢迎你！',
				path: `/pages/index/find`,
			}
		},
		onShareTimeline(res) {
			return {
				title: '陶溪川欢迎你！',
				path: '/pages/index/find',
			}
		},
		onLoad() {
			uni.setNavigationBarTitle({
				title: uni.getStorageSync('titname')
			})
			//分类
			this.$post('home/cate', {
				sign: '123',
				pid: 0,
				type: 2
			}).then(res => {
				if (res.code == 0) {
					this.$post('home/cate', {
						sign: '123',
						pid: res.data[0].id,
					}).then(res => {
						if (res.code == 0) {
							this.typeList = res.data
							this.params.cate_id = res.data[0].id
							this.gettickList()
						}
					})
				}
			})
		},
		onShareAppMessage(e) {
			return {
				title: '',
				path: '/pages/index/index'
			}
		},
		methods: {
			Bottoms() {
				this.params.page++
				this.gettickList()
			},
			toDetail(e) {
				uni.navigateTo({
					url:`/pages/index/details?id=${e.id}&&type=1`
				})
			},
			gettickList() {
				this.statusshow = 'loading'
				this.$post('tickets/ticketList', this.params).then(res => {
					if (res.code == 0) {
						this.dataList.push(...res.data.list)
						this.statusshow = 'no-more'
					}
				})
			},
			cietype(item, index) {
				this.dataList = []
				this.params.page = 1
				this.params.cate_id = item.id
				this.active = index
				this.gettickList()
			},
		}
	}
</script>

<style lang="scss">
	.find {
		display: flex;
	}

	.flex_l {
		background-color: #F5F5F5;
		height: 100vh;
		width: 180rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		text-align: center;
		position: fixed;
		left: 0%;

		.flex_l_item {
			width: 180rpx;
			height: 150rpx;
			box-sizing: border-box;

			.text {
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 30rpx;
				color: #666666;
				padding: 36rpx 24rpx;
			}

			.textactive {
				background-color: #fff;
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 30rpx;
				color: #FF7416;
				padding: 36rpx 24rpx;
			}
		}
	}

	.flex_r {
		width: 510rpx;
		margin-left: 210rpx;
		height: 90vh;
		.flex_r_item {
			width: 510rpx;
			height: 286rpx;
			margin: 30rpx 0rpx;

			.flex_item {
				border-radius: 20rpx;
				margin-bottom: 30rpx;
				position: relative;
				width: 100%;

				.imgs {
					width: 100%;
					height: 286rpx;
					border-radius: 20rpx;
				}

				.ads {
					position: absolute;
					bottom: 0%;
					width: 100%;
					height: 180rpx;
					background: linear-gradient(0deg, #100803 0%, rgba(16, 8, 3, 0.7) 31%, rgba(16, 8, 3, 0.4) 67%, rgba(16, 8, 3, 0) 100%);
					border-radius: 0rpx 0rpx 20rpx 20rpx;
					opacity: 0.9;
					display: flex;
					justify-content: space-between;
					padding: 30rpx;
					box-sizing: border-box;

					.tit {
						font-family: PingFang SC;
						font-weight: bold;
						font-size: 32rpx;
						color: #FFFFFF;
						max-width: 300rpx;
						white-space: nowrap;
						overflow: hidden;
						text-overflow: ellipsis;
					}

					.label_flex {
						display: flex;
						margin-top: 20rpx;

						.label {
							font-family: PingFang SC;
							font-weight: 500;
							font-size: 24rpx;
							color: #FFFFFF;
							border: 1px solid #fff;
							padding: 10rpx;
							border-radius: 10rpx;
							margin-right: 20rpx;
						}

						.labelts {
							font-family: PingFang SC;
							font-weight: 500;
							font-size: 24rpx;
							color: #FFFFFF;
							border: 1px solid #fff;
							padding: 10rpx;
							border-radius: 10rpx;
							margin-right: 20rpx;
							max-width: 100rpx;
							white-space: nowrap;
							overflow: hidden;
							text-overflow: ellipsis;
						}
					}

					.btn {
						min-width: 156rpx;
						font-family: PingFang SC;
						font-weight: bold;
						font-size: 30rpx;
						color: #FFFFFF;
						background-color: #FF7416;
						line-height: 66rpx;
						height: 66rpx;
						border-radius: 33rpx;
						margin-top: 60rpx;
						text-align: center;
					}

				}
			}
		}
	}
</style>